home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0039 / source / dcscreen.mod < prev    next >
Text File  |  1997-04-16  |  13KB  |  362 lines

  1. IMPLEMENTATION MODULE DCScreen;
  2.  
  3. (*---------------------------------------------------------------------*)
  4. (*   Screen Display Module for DegasConvert                            *)
  5. (*                                                                     *)
  6. (*   Functions:                                                        *)
  7. (*         Show a screen display on the screen taking account of       *)
  8. (*       the current screen resolution.                                *)
  9. (*         Display High or Medium resolution Picture on the screen.    *)
  10. (*         Convert a hi-res display to a med-res display               *)
  11. (*                                                                     *)
  12. (*   V.2: Add routine to display a picture on the full screen.         *)
  13. (*                                                                     *)
  14. (*   Version 2.0      August 1988                    L.G.Miller        *)
  15. (*                                                                     *)
  16. (*   Version 1.1      August 1987                    L.G.Miller        *)
  17. (*---------------------------------------------------------------------*)
  18.  
  19. (*---------------------------------------------------------------------*)
  20. (*                         Import List                                 *)
  21. (*---------------------------------------------------------------------*)
  22. (* IMPORT    Trace;  *)
  23.  
  24. FROM    DCGlobal        IMPORT  LowRes, MedRes, HiRes,
  25.                                 HiResScreen,     MedResScreen,
  26.                                 HiResScreenLine, MedResScreenLine, 
  27.                                 HiResMaxX,  HiResMaxY,  HiResNoPlanes,
  28.                                 MedResMaxX, MedResMaxY, MedResNoPlanes,
  29.                                 BitPlanesEnum, BITSPERWORD,
  30.                 HiRes16PixelsPtr,
  31.                 MedRes16PixelsPtr,
  32.                 TheWindow;
  33.  
  34.  
  35. FROM     DCPicCnv        IMPORT  MedRes16PixelsAddr,
  36.                 HiRes16PixelsAddr;
  37.  
  38.  
  39. FROM     DCQScrn        IMPORT  HiToMedRes;
  40.  
  41. FROM    SYSTEM          IMPORT  ADDRESS, ADR;
  42.  
  43.  
  44. IMPORT  Window;
  45.  
  46.  
  47. FROM    VDI             IMPORT  MFDB,
  48.                                 vro_cpyfm,
  49.                                 vrt_cpyfm,
  50.                                 vr_trnfm;
  51.  
  52. (* INCLUDE FOR  ManyWindows ; *)
  53.  
  54. FROM    ManyWindows     IMPORT
  55.     XYWHRect,
  56.     CornersRect,
  57.  
  58.     WindowStates,     (* = ( open, full, topped );     *)
  59.         WindowSSet,       (*  = SET OF WindowStates;    *)
  60.  
  61.     WindowPtr,    (*  = POINTER TO AWindow;    *)
  62.  
  63.         AWindow,    (*  = RECORD
  64.              Handle      : INTEGER; (* The AES window handle *)
  65.              State      : WindowSSet;
  66.              Outer,
  67.              Workarea,
  68.          PrevSize     : WindowCoordinate;
  69.              Components : ComponentSet;
  70.              Font         : FontData;                      
  71.          Title        : String;
  72.            END;  (* Window *)         
  73.  
  74. VAR    *)
  75.   AESApplId,     
  76.   VDIHandle, 
  77.   ScreenResolution,
  78.                ShowAlert,
  79.                            StartApplication, 
  80.                            CreateAWindow,
  81.                            SetAWindowTitle,
  82.                            OpenAWindow,
  83.                            ClearAWindow,
  84.                            CloseAWindow,
  85.                            DeleteAWindow,
  86.                            TerminateApplication,
  87.                            SetUpdateRect,
  88.                GetNextRect,
  89.  
  90. (* various conversion / translation utilities *)
  91.                            ToXYWHRect,
  92.                            ToCornersRect,
  93.                            QueryIntersect,
  94.                            GetWindowHandle,
  95.                            GetWindowPtr,
  96.                            BeginScreenUpdate,
  97.                            EndScreenUpdate, 
  98.                            ShowMouse,
  99.                            HideMouse;
  100. (* END ManyWindows.    *)
  101.  
  102. (*---------------------------------------------------------------------*)
  103. (*                        End Of Import List                           *)
  104. (*---------------------------------------------------------------------*)
  105.  
  106.  
  107. TYPE
  108.     BigPxyArrayType = ARRAY [ 0 .. 128 ] OF INTEGER;
  109.         SmallArrayType  = ARRAY [ 0 ..  32 ] OF INTEGER;        
  110.  
  111.         BitsetPtr     = POINTER TO BITSET; 
  112.  
  113.  
  114. (* --------------------------------------------------------------------- *)
  115. (*   Given a rectangle from GEM, draw the HiResPicture on the HiRes Scrn *)
  116. (*   Draw intersection rectangle using VDI raster operations.            *)
  117. (* --------------------------------------------------------------------- *)
  118.  
  119. PROCEDURE DrawPartialHiResScreen( VAR picture : HiResScreen;
  120.                                   PartRect    : XYWHRect ); (* partial rect *)
  121.   CONST WrModeIsReplace = 3;
  122.  
  123.   VAR OutPicMFDB, ScrnMFDB : MFDB; (* rebuild these each time for now *)
  124.       XYWHPtr : POINTER TO CornersRect;
  125.       CRect   : CornersRect;
  126.       OutPicPxyArray : BigPxyArrayType;
  127.   (* Use TheWindow size *)
  128.   BEGIN
  129.     ScrnMFDB.Block := ADDRESS(LONGCARD(0)); (* this is the screen *)
  130.     WITH OutPicMFDB DO
  131.         Block := ADR(picture);
  132.         Width   := HiResMaxX+1;
  133.         Height  := HiResMaxY+1;
  134.         WordWidth  := (HiResMaxX+1) DIV BITSPERWORD;
  135.         DeviceDependant  := BOOLEAN(0);
  136.         Planes  := 1;
  137.     END; (* with *)
  138.     XYWHPtr := ADR(OutPicPxyArray[0]);
  139.     ToCornersRect(PartRect, XYWHPtr^);
  140.     XYWHPtr := ADR(OutPicPxyArray[4]);
  141.     ToCornersRect(PartRect, XYWHPtr^);
  142.     vro_cpyfm(VDIHandle,
  143.               WrModeIsReplace,
  144.               OutPicPxyArray,
  145.               OutPicMFDB,
  146.               ScrnMFDB );
  147.   END DrawPartialHiResScreen; 
  148.  
  149.  
  150. (* --------------------------------------------------------------------- *)
  151. (*  Given a rectangle from GEM, draw the MedResPicture on the Medium     *)
  152. (*  resolution screen.                                                   *)
  153. (* --------------------------------------------------------------------- *)
  154.  
  155. PROCEDURE DrawPartialMedResScreen( VAR picture : MedResScreen;
  156.                                    PartRect : XYWHRect);(* partial rect *)
  157.   CONST WrModeIsReplace = 3;
  158.  
  159.   VAR XYWHPtr : POINTER TO CornersRect;
  160.       CRect   : CornersRect;
  161.       OutPicMFDB, ScrnMFDB : MFDB; (* rebuild these each time for now *)
  162.                                        (* global?? *)
  163.       OutPicPxyArray : BigPxyArrayType;
  164.       ColourArray    : SmallArrayType;
  165.   (* Use TheWindow size *)
  166.   BEGIN
  167.     ScrnMFDB.Block := ADDRESS(LONGCARD(0)); (* this is the screen *)
  168.     WITH OutPicMFDB DO
  169.         Block := ADR(picture);
  170.         Width   := MedResMaxX+1;
  171.         Height  := MedResMaxY+1;
  172.         WordWidth  := (MedResMaxX+1) DIV BITSPERWORD;
  173.         DeviceDependant  := BOOLEAN(0);
  174.         Planes  := 2;
  175.     END; (* with *)
  176.  
  177.     XYWHPtr := ADR(OutPicPxyArray[0]);
  178.     ToCornersRect(PartRect, XYWHPtr^);
  179.     XYWHPtr := ADR(OutPicPxyArray[4]);
  180.     ToCornersRect(PartRect, XYWHPtr^);
  181.     ColourArray[0]:=0;
  182.     ColourArray[1]:=1;
  183.     vro_cpyfm(VDIHandle,
  184.               WrModeIsReplace,
  185.               OutPicPxyArray,
  186.               OutPicMFDB,
  187.               ScrnMFDB)
  188.   END DrawPartialMedResScreen; 
  189.  
  190.  
  191.  
  192. (*----------------------------------------------------------------------*)
  193. (* For colour users rearrange a hi-res screen into a med-res screen     *)
  194. (*                                                                      *)
  195. (* Two hi-res screen lines make one med-res line.                       *)
  196. (*----------------------------------------------------------------------*)
  197. PROCEDURE ConvertHiToMedResDisplay ( VAR hiresdisplay  : HiResScreen;
  198.                                      VAR medresdisplay : MedResScreen );
  199.  
  200.   BEGIN
  201.     HiToMedRes( hiresdisplay, medresdisplay );
  202.   END ConvertHiToMedResDisplay;
  203.  
  204.  
  205.  
  206. PROCEDURE DisplayFullMedResPicture( VAR picture : MedResScreen );
  207.   CONST WrModeIsReplace = 3;
  208.  
  209.   VAR XYWHPtr : POINTER TO CornersRect;
  210.       FullRect : XYWHRect; (* display rect co-ords *)
  211.       OutPicMFDB, ScrnMFDB : MFDB; (* rebuild these each time for now *)
  212.       OutPicPxyArray : BigPxyArrayType;
  213.       ColourArray    : SmallArrayType;
  214.   (* Use FULL SCREEN SIZE *)
  215.   BEGIN
  216.     ScrnMFDB.Block := ADDRESS(LONGCARD(0)); (* this is the screen *)
  217.     WITH OutPicMFDB DO
  218.         Block := ADR(picture);
  219.         Width   := MedResMaxX+1;
  220.         Height  := MedResMaxY+1;
  221.         WordWidth  := (MedResMaxX+1) DIV BITSPERWORD;
  222.         DeviceDependant  := BOOLEAN(0);
  223.         Planes  := 2;
  224.     END; (* with *)
  225.  
  226.     WITH FullRect DO
  227.       X     := 0;
  228.       Y     := 0;
  229.       Width      := MedResMaxX+1;
  230.       Height     := MedResMaxY+1;
  231.     END;
  232.  
  233.     XYWHPtr := ADR(OutPicPxyArray[0]);
  234.     ToCornersRect(FullRect, XYWHPtr^);
  235.     XYWHPtr := ADR(OutPicPxyArray[4]);
  236.     ToCornersRect(FullRect, XYWHPtr^);
  237.     ColourArray[0]:=0;
  238.     ColourArray[1]:=1;
  239.     vro_cpyfm(VDIHandle,
  240.               WrModeIsReplace,
  241.               OutPicPxyArray,
  242.               OutPicMFDB,
  243.              ScrnMFDB)
  244.   END DisplayFullMedResPicture;
  245.  
  246.  
  247. (* --------------------------------------------------------------------- *)
  248. (*  Draw the Full picture on the hi-res screen.                          *)
  249. (* --------------------------------------------------------------------- *)
  250.  
  251. PROCEDURE DisplayFullHiResPicture( VAR picture : HiResScreen );
  252.   CONST WrModeIsReplace = 3;
  253.  
  254.   VAR XYWHPtr : POINTER TO CornersRect;
  255.       FullRect : XYWHRect; (* display rect co-ords *)
  256.       OutPicMFDB, ScrnMFDB : MFDB; (* rebuild these each time for now *)
  257.       OutPicPxyArray : BigPxyArrayType;
  258.   (* Use TheWindow size *)
  259.   BEGIN
  260.     ScrnMFDB.Block := ADDRESS(LONGCARD(0)); (* this is the screen *)
  261.     WITH OutPicMFDB DO
  262.         Block := ADR(picture);
  263.         Width   := HiResMaxX+1;
  264.         Height  := HiResMaxY+1;
  265.         WordWidth  := (HiResMaxX+1) DIV BITSPERWORD;
  266.         DeviceDependant  := BOOLEAN(0);
  267.         Planes  := 1;
  268.     END; (* with *)
  269.  
  270.  
  271.     WITH FullRect DO
  272.       X     := 0;
  273.       Y     := 0;
  274.       Width      := HiResMaxX+1;
  275.       Height     := HiResMaxY+1;
  276.     END;
  277.  
  278.     XYWHPtr := ADR(OutPicPxyArray[0]);
  279.     ToCornersRect(FullRect, XYWHPtr^);
  280.     XYWHPtr := ADR(OutPicPxyArray[4]);
  281.     ToCornersRect(FullRect, XYWHPtr^);
  282.     vro_cpyfm(VDIHandle,
  283.               WrModeIsReplace,
  284.               OutPicPxyArray,
  285.               OutPicMFDB,
  286.               ScrnMFDB );
  287.   END DisplayFullHiResPicture;
  288.  
  289.  
  290. (*----------------------------------------------------------------------*)
  291. (* Show picture, convert to hi-res screen if required...                *)
  292. (*----------------------------------------------------------------------*)
  293. VAR ms : MedResScreen; (* declare this as a GLOBAL variable *)
  294.  
  295. PROCEDURE DisplayPicture ( VAR hirespicture : HiResScreen );
  296.   BEGIN
  297.     IF ScreenResolution = HiRes THEN
  298.        DisplayHiResPicture( hirespicture );
  299.     ELSE
  300.        ConvertHiToMedResDisplay( hirespicture, ms );
  301.        DisplayMedResPicture( ms );
  302.     END;
  303.   END DisplayPicture;
  304.  
  305.  
  306.  
  307. (* ----------------------------------------------------------------- *)
  308. (*  DRAW SCREEN   will only work in hi-res & med-res                 *)
  309. (* ----------------------------------------------------------------- *)
  310.  
  311. (* --------------------------------------------------------------------- *)
  312. (* Draw the screen ( Hi or Medium res ). The method used is the one      *)
  313. (* recommended for GEM of 'walking' the rectangle list.                  *)
  314. (* --------------------------------------------------------------------- *)
  315. PROCEDURE DisplayHiResPicture ( VAR picture : HiResScreen );
  316.  
  317.   VAR  UpdateWindow : BOOLEAN; 
  318.        RedrawRect   : XYWHRect;     
  319.   BEGIN
  320.     HideMouse;
  321.     SetUpdateRect( TheWindow, TheWindow^.Workarea );
  322.     UpdateWindow := GetNextRect(TheWindow, RedrawRect);
  323.     WHILE UpdateWindow DO
  324.       DrawPartialHiResScreen(picture, RedrawRect);
  325.       UpdateWindow := GetNextRect(TheWindow, RedrawRect);
  326.     END; (* while *)
  327.     ShowMouse;    
  328.   END DisplayHiResPicture;
  329.  
  330.  
  331. PROCEDURE DisplayMedResPicture ( VAR picture : MedResScreen );
  332.  
  333.   VAR  UpdateWindow : BOOLEAN; 
  334.        RedrawRect   : XYWHRect;     
  335.   BEGIN
  336.     HideMouse;
  337.     SetUpdateRect( TheWindow, TheWindow^.Workarea );
  338.     UpdateWindow := GetNextRect(TheWindow, RedrawRect);
  339.     WHILE UpdateWindow DO
  340.       DrawPartialMedResScreen(picture, RedrawRect);
  341.       UpdateWindow := GetNextRect(TheWindow, RedrawRect);
  342.     END; (* while *)
  343.     ShowMouse;    
  344.   END DisplayMedResPicture;
  345.  
  346.  
  347. (*----------------------------------------------------------------------*)
  348. (* Show FULL picture, convert to hi-res screen if required...           *)
  349. (*----------------------------------------------------------------------*)
  350. PROCEDURE DisplayFullPicture ( VAR hirespicture : HiResScreen );
  351.   BEGIN
  352.     IF ScreenResolution = HiRes THEN
  353.        DisplayFullHiResPicture( hirespicture );
  354.     ELSE
  355.        ConvertHiToMedResDisplay( hirespicture, ms );
  356.        DisplayFullMedResPicture( ms );
  357.     END;
  358.   END DisplayFullPicture;
  359.  
  360.  
  361. END DCScreen.
  362.